jQuery(document).ready(function(){  

    jQuery('#bus-more').bind('click', function(){
        bus_tours('montenegro_tour');
    });
    jQuery('#bus-tours').bind('change', function(){
        if($(this).val()==0)return;
        bus_tours($(this).val());
    }) 

    function bus_tours(id){
        $('#'+id).modal({
            opacity: 80,
            containerCss:{
                width: '711px',
                height: '650px',
                background: 'transparent',
                border: 0,
                padding: 0
            },
            onOpen: function (dialog) {
                dialog.data.hide();
                dialog.overlay.fadeIn('slow', function () {
                    dialog.container.fadeIn('slow', function () {
                        dialog.data.slideDown('slow',function(){
                            $('.zmodalClose').fadeIn('fast');
                        });
                    });
                });
            },
            onClose: function (dialog) {
                dialog.data.fadeOut('slow', function () {
                    dialog.container.slideUp('slow', function () {
                        dialog.overlay.fadeOut('slow', function () {
                            $.modal.close(); // must call this!
                            jQuery('#bus-tours').val('0'); 
                        });
                    });
                });
            },
            closeClass: 'zmodalClose'
        });
        jQuery('.zmodalClose').css({
            'margin-right':'22px',
            'margin-top':'4px',
            'display':'none'
        });
    }
    jQuery('.partner-trigger-open').bind('click',function(){
        jQuery('#partners-div-holder').css('display','block');
    })
    jQuery('#close-partners-trigger').live('click',function(){
        jQuery('#partners-div-holder').fadeOut();
    })
    // Display an external page using an iframe
    var src = base_url+"assets/html/panoramska-mapa.html";
    jQuery(".open-map").live('click',function(){
        $.modal('<iframe id="DP_Log_frame" name="DP_Log_frame" src="' + src + '" height="600" width="1600" style="border:0" scrolling="no">', {
            opacity: 50,
            containerCss:{
                backgroundColor:"#fff",
                borderColor:"#fff",
                height:617,
                padding:0,
                width:942
            },
            overlayClose:true,                
            onOpen: function (dialog) {
                dialog.data.hide();
                dialog.overlay.fadeIn('fast', function () {
                    dialog.container.fadeIn('fast', function () {
                        dialog.data.slideDown('normal',function(){
                            jQuery('.zmodalClose').fadeIn('fast');
                        });
                    });
                });
            },
            closeClass: 'zmodalClose2'
        }); 
    });
    $('.zmodalClose2').css({
        'right':'0px',
        'top':'0px',
        'display':'none'
    }); 
    jQuery('#katalog-sel').bind('change', function(){
        var file = this.value;
        if(file!=0){
            var pdf_url = base_url+'assets/pdf/'+this.value;
            poptastic (pdf_url);
            jQuery('#katalog-sel').val('0');     
        }
    }
    )
    jQuery('#hotel-sel').bind('change', function(){
        jQuery('#hotel').val('0');
        jQuery('#hotel').submit();

    })
    var newwindow;
    function poptastic(url)
    {
        newwindow=window.open(url,'name','height=600,width=540');
        if (window.focus) {newwindow.focus()}
    }
    $('#sea').bind('click',function(){
        var so = new FlashObject(base_url+"assets/flash/pageflip_loader_36.swf", "Loader", "940", "740", "8", "#FFFFFF");
        so.addVariable("b", base_url);
        so.addVariable("p", p);
        so.addParam('allowfullscreen','false');
        so.addParam('allowscriptaccess','always');
        so.addParam('wmode','opaque'); 
        so.write('menu');
        $('#content_menu_holder').show();
        $('#smallwrap').addClass('absolute_fix');
    })
    $('.zseaClose').live('click',function(){
        $('#content_menu_holder').hide();
        $('#menu').html("");
        $('#smallwrap').removeClass('absolute_fix');
    })
});
$(window).load(function() {
    for(i=1;i<=4;i++){ 
        $('#slider-'+i).nivoSlider({
            effect:'fade', //Specify sets like: 'random,fold,fade,sliceDown'
            slices:1,
            animSpeed:500, //Slide transition speed
            pauseTime:7000,
            captionOpacity:0.8, //Universal caption opacity 
            pauseOnHover:false,
            directionNav:false, //Next & Prev
            controlNav:false //1,2,3...
        });
    }          
});